/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Andre
 */
@Entity
@Table(name = "tipoEndereco")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TipoEndereco.findAll", query = "SELECT t FROM TipoEndereco t"),
    @NamedQuery(name = "TipoEndereco.findByIdTipoEndereco", query = "SELECT t FROM TipoEndereco t WHERE t.idTipoEndereco = :idTipoEndereco"),
    @NamedQuery(name = "TipoEndereco.findByDescricao", query = "SELECT t FROM TipoEndereco t WHERE t.descricao = :descricao")})
public class TipoEndereco implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "idTipoEndereco")
    private Integer idTipoEndereco;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "descricao")
    private String descricao;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tipoEndereco")
    private List<Endereco> enderecoList;

    public TipoEndereco() {
    }

    public TipoEndereco(String descricao) {
        this.descricao = descricao;
    }

    public Integer getIdTipoEndereco() {
        return idTipoEndereco;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    @XmlTransient
    public List<Endereco> getEnderecoList() {
        return enderecoList;
    }

    public void setEnderecoList(List<Endereco> enderecoList) {
        this.enderecoList = enderecoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTipoEndereco != null ? idTipoEndereco.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TipoEndereco)) {
            return false;
        }
        TipoEndereco other = (TipoEndereco) object;
        if ((this.idTipoEndereco == null && other.idTipoEndereco != null) || (this.idTipoEndereco != null && !this.idTipoEndereco.equals(other.idTipoEndereco))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return descricao;
    }
    
}
